<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .box1{
        width: 300px;
        height: 300px;
        border:  solid red;

    }
    .box2{
        width: 100px;
        height: 100px;
        background-color: black;
    }
</style>
<body>
    <div class="box1">
        <div class="box2">
        
        </div>
    </div>
</body>
<script>
    // 练习:单击时触发单击事件， 双击时只触发双击事件
    // BOM:setTimeOut()
        var btn = document.querySelector('.box1')
        var btn1 = document.querySelector('.box2')
        btn.addEventListener('click',fn)
        btn1.addEventListener('dblclick',fn1);
        var time 
        function fn() {
            clearTimeout(time)
            time=setTimeout( function() {
            alert('2班')
        },500)
        }
       
        function fn1() {
            clearTimeout(time)
            alert('4班')
        }
    </script>
</html>